<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function arr(s) {
      let valid = true;
      let res = 0;
      for (let i = 0; i < s.length; i++) {
        let c = s[i];
        if (c === '|') {
          valid = !valid;
        } else if (c === '*' && valid) {
          res++;
        }
      }
      return res;
    };
    console.log(arr(s = "l|*e*et|c**o|*de|"));
  </script>
</body>

</html>